FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9 as requirements-stage

WORKDIR /tmp/

# Install Poetry
RUN pip install poetry

# Copy poetry.lock* in case it doesn't exist in the repo
COPY app/pyproject.toml app/poetry.lock* /tmp/

# 生成 requirements.txt
RUN poetry export -f requirements.txt --output requirements.txt --without-hashes

FROM python:3.9

EXPOSE 8000

WORKDIR /code

COPY --from=requirements-stage /tmp/requirements.txt /code/requirements.txt

RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

COPY app /code/

CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000","--env-file","app/config/pro_tx.env"]
